package com.google.code.datastructure;

import java.util.Iterator;

import org.jsoup.nodes.Element;

public abstract class TreeSearch {
	public Element DFS(Element el) {
		Element _el = this.process(el);
		if (_el != null)
			return _el;

		Iterator<Element> els = el.children().iterator();
		while (els.hasNext()) {
			_el = els.next();
			_el = DFS(_el);
			if (_el != null)
				return _el;
		}
		return null;
	}

	public abstract Element process(Element el);
}
